<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <%@ include file="/WEB-INF/views/include/head.jsp"%> 
        <link rel="stylesheet" href="${ctxStatic}/css/list.css">
        <script>
            $(function(){
                $("#styleCategoryCd,#styleFitCd,#styleSizeGroupCd,#styleSizeCd").select2();
            });
            
                //重置
               function clean(){
                   $("#searchForm")[0].reset();  
                    $('#styleCategoryCd').val('');
                    $("#styleCategoryCd").select2(); 
                    $('#styleFitCd').val('');
                    $("#styleFitCd").select2(); 
                    $('#styleSizeGroupCd').val('');
                    $("#styleSizeGroupCd").select2(); 
                    $('#styleSizeCd').val('');
                    $("#styleSizeCd").select2(); 
                    $("#searchForm").submit();
               }
            
                //尺码组联动
                function subStyleSize(t,id){
                    var code=$(t).find("option:selected").attr("data-value");
                    var param={"code":code};
                    $.post("${ctx}/custom/size/styleSize",param,function(result){
                        var html="<option value=''><spring:message code='size_pleaseChoosed'/></option>";
                        $.each(result,function(i,e){
                            html+="<option value='"+e.itemCode+"-"+e.itemValue+"'>"+e.itemName+"</option>";
                        });
                        $("#"+id).html(html);
                        $("#"+id).select2();
                    },'json');
                }
        </script>
    </head>
    <body>
        <form  id="searchForm" action="${ctx}/custom/size/list" method="post">
        <c:set value="<%=ResourcesUtil.getConfig(\"size_styleCategory\")%>" var="styleCategory" />
        <c:set value="<%=ResourcesUtil.getConfig(\"size_styleFitCd\")%>" var="styleFit" />
        <c:set value="<%=ResourcesUtil.getConfig(\"size_styleSizeGroupCd\")%>" var="sizeGroup" />
        <input id="pageNo" name="pageNo" type="hidden" value="${page.pageNo}"/>
        <input id="pageSize" name="pageSize" type="hidden" value="${page.pageSize}"/>
            <div class="listSearchBox clearfix">
                <div class="searchLeft clearfix">
                    <div class="searchSm clearfix">
                        <!-- 款式类别 -->
                        <p class="searchTxt"><spring:message code="size_styleCategory"/></p>
                        <div class="searchInp">
                            <select style="width:100px" id="styleCategoryCd" name="styleCategoryCd"  >
                             <option value=""><spring:message code="size_pleaseChoosed"/></option>
                              <c:forEach items="${fns:getDictList(styleCategory)}"   var="category">
                                 <option  <c:if test="${fn:split(size.styleCategoryCd,'-')[1] eq category.itemValue}">selected="selected"</c:if> value="${category.itemCode}-${category.itemValue}" > 
                                     ${category.itemName}
                                 </option>
                             </c:forEach>
                         </select>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 版型 -->
                        <p class="searchTxt"><spring:message code="size_styleFit"/></p>
                        <div class="searchInp">
                            <select style="width:100px" id="styleFitCd" name="styleFitCd"  >
                                 <option value=""><spring:message code="size_pleaseChoosed"/></option>
                                  <c:forEach items="${fns:getDictList(styleFit)}"   var="fit">
                                     <option  <c:if test="${fn:split(size.styleFitCd,'-')[1] eq fit.itemValue}">selected="selected"</c:if> value="${fit.itemCode}-${fit.itemValue}" > 
                                         ${fit.itemName}
                                     </option>
                                 </c:forEach>
                             </select>
                        </div>
                    </div>
                    <div class="searchSm clearfix">
                        <!-- 尺码组 -->
                        <p class="searchTxt SizeListWidth"><spring:message code="size_sizeGroup"/></p>
                        <div class="searchInp">
                            <select style="width:100px" id="styleSizeGroupCd" name="styleSizeGroupCd" onchange="subStyleSize(this,'styleSizeCd')" data-rule-required="true" data-msg-required="<spring:message code="fitproperty_pleaseChoosedUnit"/>" >
                             <option value=""><spring:message code="size_pleaseChoosed"/></option>
                              <c:forEach items="${fns:getDictList(sizeGroup)}"   var="group">
                                 <option data-value="${group.itemValue}" <c:if test="${fn:split(size.styleSizeGroupCd,'-')[1] eq group.itemValue}">selected="selected"</c:if> value="${group.itemCode}-${group.itemValue}" > 
                                     ${group.itemName}
                                 </option>
                             </c:forEach>
                         </select>
                        </div>
                        <div class="searchInp">
                            <select style="width:100px"  id="styleSizeCd" name="styleSizeCd" >
                            <option value=""><spring:message code="size_pleaseChoosed"/></option>
                            <c:forEach items="${fns:getDictList(fn:split(size.styleSizeGroupCd, '-')[1])}" var="styleSize">
                                <option 
                                    <c:if test="${fn:split(size.styleSizeCd, '-')[1] eq styleSize.itemValue}">selected="selected"</c:if>  value="${styleSize.itemCode}-${styleSize.itemValue}">
                                    ${styleSize.itemName}
                                </option>
                            </c:forEach>
                        </select>
                        </div>
                    </div>
                </div>
                <div class="searchRight">
                    <!-- 新建 -->
                    <shiro:hasPermission name="custom:size:edit">
                        <button type="button" class="btn-cj" onclick="popup('935px','550px','${ctx}/custom/size/form')"><spring:message code="common_create"/></button>
                    </shiro:hasPermission>
                    <!-- 重置 -->
                    <button type="button" class="btn-js" onclick="clean();"><spring:message code="common_reset"/></button>
                    <!-- 查询 -->
                    <button type="button" class="btn-js" onclick="return page();"><spring:message code="commom_check"/></button>
                </div>
            </div>
        </form>
        <div class="tableBox">
            <div class="tableBoxScroll">
                <div class="tabScroll">
                <table cellpadding="0" class="tableCon">
                    <thead>
                    <tr>
                        <!-- 序号No. -->
                        <th style="width:136px"><spring:message code="common_no"/></th>
                        <!-- 款式类别 -->
                        <th style="width:136px"><spring:message code="size_styleCategory"/></th>
                        <!-- 版型 -->
                        <th style="width:137px"><spring:message code="size_styleFit"/></th>
                        <!-- 尺码组 -->
                        <th style="width:139px"><spring:message code="size_sizeGroup"/></th>
                        <!-- 尺码 -->
                        <th style="width:137px"><spring:message code="size_size"/></th>
                        <!-- 状态 -->
                        <th style="width:137px"><spring:message code="size_state"/></th>
                        <!-- 更新人 -->
                        <th style="width:139px"><spring:message code="size_update_user"/></th>
                        <!-- 更新日期 -->
                        <th style="width:226px"><spring:message code="size_update"/></th>
                    </tr>
                    </thead>
                    <tbody>
                        <c:forEach items="${page.list}" var="size" varStatus="status">
                            <tr>
                                <td>
                                    <p>${(page.pageNo-1)*page.pageSize + status.index+1}</p>
                                </td>
                                <td>
                                    <p data-toggle="tooltip" title="${fns:getDictName(size.styleCategoryCd)}">${fns:getDictName(size.styleCategoryCd)}</p>
                                </td>
                                <td>
                                    <p data-toggle="tooltip" title="${fns:getDictName(size.styleFitCd)}">${fns:getDictName(size.styleFitCd)}</p>
                                </td>
                                <td>
                                    <p data-toggle="tooltip" title="${fns:getDictName(size.styleSizeGroupCd)}">${fns:getDictName(size.styleSizeGroupCd)}</p>
                                </td>
                                <td>
                                    <p class="show" onclick="popup('800px','470px','${ctx}/custom/size/show?id=${size.id}')">${fns:getDictName(size.styleSizeCd)}</p>
                                </td>
                                <td>
                                    <c:choose>
                                        <c:when test="${size.enableFlag eq 1}"><spring:message code="size_enable"/></c:when>
                                        <c:when test="${size.enableFlag eq 0}"><spring:message code="size_disable"/></c:when>
                                    </c:choose>
                                </td>
                                <td>
                                    <p>${size.createBy.firstName}${size.createBy.lastName}</p>
                                </td>
                                <td>
                                    <p><fmt:formatDate value="${size.createDate}" pattern="yyyy-MM-dd HH:mm" /></p>
                                </td>
                            </tr>
                        </c:forEach>
                    </tbody>
                </table>
                <c:if test="${empty page.list}" >
                    <div class="tableNone">
                        <img src="${ctxStatic}/images/icon-03.png" height="20"> <spring:message code="There_is_no_data"/>
                    </div>
                </c:if>
                </div>
            </div>
            <%@ include file="/WEB-INF/views/include/page.jsp"%>
        </div>
        <script>
            window.onload = function() {
                tableH()
            }
            window.onresize = function() {
                tableH()
            }
        </script>
    </body>
</html>